<?php
/**
*   版本号
*/
namespace app\api\model;
use think\Model;

class Version extends Model
{
    /**
    *   列表
    */
    public function _list($where = 'status = 1', $order_by="sort desc", $page_size = PAGE_SIZE_API){
        $obj = $this->order($order_by);
        $data = $this->where($where)
            ->field('id, title, code, num, link, summary')
            ->order($order_by)
            ->paginate($page_size)
            ->toArray();
        return $data;
    }
    

    /**
    * 检测是否需要更新app
    * @param num 当前版本号
    * @return bool true 需要更新 false：不用更新
    */
    public function _checkUpdate($num){
        $data = $this->where([['status', '=', 1]])->order("sort desc")->find();
        if(empty($data)){
            return false;
        }
        //var_dump($data);die;
        if($num < $data['sort']){
            return $data;
        }
        
        return false;
    }
    


}